﻿function show_confirm(textid, filename, text){
	var r = confirm("Сигурни ли сте, че искате да премахнете този ред, като негоден за превод?\n\nТЕКСТ: "+text);
	if(r==true){
		remove_text(textid, filename);
	}
	else{
		return;
	}
}

function remove_text(textid, filename){
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function(){
		document.getElementById("is_for_translation_"+textid).innerHTML = "";
	}
	xmlhttp.open("GET","update_text.php?text_id="+textid+"&file_name="+filename, true);
	xmlhttp.send();
}

function edit_text(textid, filename, text, game){
	document.getElementById("edit_"+textid).innerHTML = "<div id='edit_text_"+textid+"' style='display: inline;'><table><tr><td rowspan='2'><textarea id='is_editing_"+textid+"' cols='80' rows='1' style='resize: vertical;'>"+text+"</textarea></td><td><img src='./icons/check_icon.png' alt='Одобри' style='cursor: pointer;' onclick=\"edit_text_yes('"+textid+"', '"+filename+"', '"+game+"')\"></td></tr><tr><td><img src='./icons/cancel_icon.png' alt='Отхвърли' style='cursor: pointer;' onclick=\"edit_text_no('"+textid+"', '"+filename+"', '"+text+"')\"></td></tr></table></div>";
}

function edit_text_yes(textid, filename, game){
	var text = document.getElementById("is_editing_"+textid).value;
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function(){
		document.getElementById("edit_text_"+textid).innerHTML = "<div id='edit_"+textid+"' style='display: inline;'><span style='color:green'>"+text+" </span><img src='./icons/edit_icon.png' alt='Редактирай превод' style='cursor: pointer;' onclick=\"edit_text('"+textid+"', '"+filename+"', '"+text+"')\"></div>";
	}
	xmlhttp.open("GET","edit_text.php?game="+game+"&text_id="+textid+"&file_name="+filename+"&content="+text, true);
	xmlhttp.send();
}

function edit_text_no(textid, filename, text){
	document.getElementById("edit_text_"+textid).innerHTML = "<div id='edit_"+textid+"' style='display: inline;'><span style='color:green'>"+text+" </span><img src='./icons/edit_icon.png' alt='Редактирай превод' style='cursor: pointer;' onclick=\"edit_text('"+textid+"', '"+filename+"', '"+text+"')\"></div>";
}